﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Faust.Andrew.MTG.Player
{
	/// <summary>
	/// Interaction logic for InputBox.xaml
	/// </summary>
	public partial class InputBox : Window
	{
		public InputBox()
		{
			this.InitializeComponent();
			
			// Insert code required on object creation below this point.
		}

        private string _value;
        public string Value
        {
            get { return _value; }
            set
            {
                _value = value;
                txtInput.Text = _value;
            }
        }

        public string Prompt
        {
            get { return txtPrompt.Text; }
            set
            {
                txtPrompt.Text = value;
            }
        }
        
        public static string ShowInput(string prompt, string defaultValue)
        {
            InputBox inputBox = new InputBox();
            inputBox.Prompt = prompt;
            inputBox.Value = defaultValue;

            inputBox.ShowDialog();

            return inputBox.Value;
        }

		private void btnOK_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            _value = txtInput.Text;
            Close();
		}

		private void btnCancel_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            _value = null;
            Close();
		}
	}
}